package 集合框架;

import java.util.ArrayList;
import java.util.Collections;

public class PersonTest {


    public static void a() {
        ArrayList<Person> list = new ArrayList<>();
        Person p1 = new Person(1, "张三", 20);
        Person p2 = new Person(2, "李四", 22);
        Person p3 = new Person(3, "王五", 29);
        Person p4 = new Person(4, "王九", 18);
        Person p5 = new Person(4, "王九", 18);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        boolean b = list.contains(p5);
        System.out.println(b);
        System.out.println(p4 == p5);
        System.out.println(p4.equals(p5));
    }

    public static void b(){
        ArrayList<Person> list = new ArrayList<>();
        Person p1 = new Person(1, "张三", 20);
        Person p2 = new Person(2, "李四", 22);
        Person p3 = new Person(3, "王五", 29);
        Person p4 = new Person(4, "王九", 18);
        Person p5 = new Person(5, "王九", 10);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        list.add(p4);
        list.add(p5);
        list.forEach(System.out::println);
        //调用排序方法
        Collections.sort(list);
        System.out.println("===================================");
        list.forEach(System.out::println);
    }

    public static void main(String[] args) {
        b();
    }
}
